<?php defined('IN_HOPECMS') or exit('Access Denied'); ?>
<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title><?php echo $page_title; ?></title>
		<link href="{__URL__}resources/css/login.css" rel="stylesheet" type="text/css" />
		<link href="{__PUBLIC__}css/dpAlert.css" rel="stylesheet" type="text/css" />
		<script type=text/javascript src="{__PUBLIC__}script/jquery.js"></script>
		<script type=text/javascript src="{__URL__}resources/script/dp_form.js"></script>
		<script type=text/javascript src="{__PUBLIC__}script/dpAlert.js"></script>
	</head>
<body>
	<div id="top"></div>
	<div id="middle">
		<div id="login">
			<form name="login">
				<label>
					<input type="text" name="username" id="username" class="text" autocomplete="off" />
					<span id="u">请输入用户名...</span>
				</label>
				<label>
					<input type="password" name="password" id="password" class="text" />
					<span id="u">请输入密码...</span>
				</label>
				<input type="hidden" name="token" id="token" value="<?php echo $token_code; ?>" />
				<input type="submit" value="登 陆" class="button" id="submit_login" />
			</form>
		</div>
	</div>
	<script type="text/javascript">
	$(function(){
		$('#username').focus().css({border:'1px solid #222'});
		$('#username, #password').focus(function(){
			$(this).css({border:'1px solid #222'});
		}).blur(function(){
			$(this).css({border:'1px solid #ccc'});
		});
		input('#username');
		input('#password');
		$('form[name=login]').submit(function(){
			if ($('#username').val() == '') {
				dpAlert(this, {
					callback : 'alerts',
					height : '200',
					title:'提示',
					content:'请输入用户名。。。'
				});
				return false;
			}

			if ($('#password').val() == '') {
				dpAlert(this, {
					callback : 'alerts',
					height : '200',
					title:'提示',
					content:'请输入密码。。。'
				});
				return false;
			}
			$.ajax({
				url : '<?php echo D::createUrl("admin/index/login"); ?>',
				dataType : 'json',
				type : 'POST',
				data : {username : $('#username').val(), password : $('#password').val(), token : $('#token').val()},
				success : function (data) {
					if (data.code == 0) {
						dpAlert(this, {
							callback : 'alerts',
							height　 : 200,
							title    : '提示',
							content  : '用户名或密码错误'
						});
					} else {
						window.location = data.url;
					}
				}
			});
			return false;
		})
	});
	</script>
	<div id="bottom"></div>
</body>
</html>